package com.xingkeduo.business.operation.controller.cms;

import com.xingkeduo.business.operation.domain.PermsDomain;
import com.xingkeduo.business.operation.domain.cms.MenuDomain;
import com.xingkeduo.pojo.json.cms.MenuJson;
import com.xingkeduo.pojo.table.PermsTable;
import com.xingkeduo.util.pojo.base.BaseController;
import com.xingkeduo.util.tool.ReturnUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.web.bind.annotation.*;
import sun.tools.jar.Main;

import java.util.List;

import static com.xingkeduo.tool.OperaConstants.CMS_URL_PREFIX;

/**
 * 文件概述
 *
 * @author wangxilong <wangxilong@xingkeduo.com>
 * @version id:v0.1 19-1-17 下午6:22
 * @package BeautyOS
 * @copyright Copyright (c) XKD 2019
 */
@RestController
@RequestMapping(CMS_URL_PREFIX + "/main")
public class MainController extends BaseController {
    @Autowired
    private PermsDomain permsDomain;

    //首页
    @RequestMapping(value = "/menu", method = RequestMethod.GET)
    public String menu(ServerHttpRequest request) {
        //获取菜单
        returnUtil = new ReturnUtil();
        try {
            Long userId =this.getOperator(request);
            List<PermsTable> permsTables =  permsDomain.getMenu(userId);
            return returnUtil.getSuccess(MenuJson.toJson(permsTables));
        } catch (Throwable throwable) {
            return dealException(throwable, returnUtil);
        }

    }
}
